package com.tengol.demo.design.pattern.structural.flyweight.demo2;

import java.util.HashMap;
import java.util.Map;

/**
 * WebSiteFactory
 *
 * @author dongrui
 * @date 2019/03/07
 */
public class WebSiteFactory {
    private static final Map<String,WebSite> WEB_SITE_MAP = new HashMap<String, WebSite>();

    public static WebSite getWebSite(String name){
        if(WEB_SITE_MAP.containsKey(name)){
            return WEB_SITE_MAP.get(name);
        }else{
            ConcreteWebSite concreteWebSite = new ConcreteWebSite(name);
            WEB_SITE_MAP.put(name,concreteWebSite);
            return concreteWebSite;
        }
    }

    //获得网站分类总数
    public static int getSize(){
        return WEB_SITE_MAP.size();
    }
}
